<template>
  <div class="addExpense">
    <priceDetails :form="detailData" />
    <div style="text-align: center">
      <el-button
        type="primary"
        @click="$router.push('/product/promotionPriceManage')"
      >返回</el-button>
    </div>
  </div>
</template>

<script>
import priceDetails from '../components/details'
export default {
  components: { priceDetails },
  data() {
    return {
      detailData: {}
    }
  },
  mounted() {
    if (this.$route.query && this.$route.query.id) {
      this.getDetailData(this.$route.query.id)
    }
  },
  methods: {
    getDetailData(id) {
      this.$http
        .get(`/productSalesPrice/${id}`)
        .then((res) => {
          if (res.code == 10000) {
            this.detailData = res.data
            this.detailData['product'] = res.data.list.map(e => {
              e['category_text'] = `${e.parent_name}-${e.category_name}`
              return e
            })
            this.detailData.start_time = this.timestampToTime(this.detailData.start_time)
            this.detailData.end_time = this.timestampToTime(this.detailData.end_time)
          }
        })
        .catch((err) => {
          console.log(err)
        })
    }
  }
}
</script>

<style scoped>
.addExpense {
  padding: 15px;
  background: #fff;
}
/deep/.el-select,
.el-autocomplete {
  width: 100%;
}
</style>
